using UnityEngine;
using System.Collections;

public class TextBlink : MonoBehaviour 
{
    public string level;
    public float blinkTime = 0.5f;
    public GameObject fadeOut;

	void Start () 
    {
        InvokeRepeating("Blink", 0, blinkTime);
	}

	void Update () 
    {
	    if(Input.anyKeyDown)
        {
            fadeOut.SetActive(true);
            StartCoroutine("FadeOut");
        }
    }

    void Blink()
    {
        renderer.enabled = !renderer.isVisible;
    }

    IEnumerator FadeOut()
    {
        yield return new WaitForSeconds(1);
        Application.LoadLevel(level);
    }
}
